// components/lunbo/lunbo.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: String,
    glist: Object
  },

  /**
   * 组件的初始数据
   */
  data: {
    movies: [],
    list: {
      dbName: 'movies',
      pageIndex: 1,
      pageSize: 10,
      filter: ".*",
      orderBy: 'rate',
      state: 'desc'
    }
  },
  observers: {
    'glist': function (val) {
      this.setData({
        list: val
      })
      this.getData();
    }
  },
  created: function () {

  },
  /**
   * 组件的方法列表
   */
  methods: {
    async getData() {
      let that = this;
      await wx.cloud
        .callFunction({
          name: 'movielist',
          data: {
            dbName: that.data.list.dbName,
            pageIndex: that.data.list.pageIndex,
            pageSize: that.data.list.pageSize,
            filter: that.data.list.filter,
            orderBy: that.data.list.orderBy,
            state: that.data.list.state
          },
        })
        .then((res) => {
          that.setData({
            movies: res.result.data
          });
        });
    },
  }
})
